package com.qfedu.api.controller.sms;


import com.qfedu.common.api.CommonResult;
import com.qfedu.mbg.model.SmsStaff;
import com.qfedu.service.SmsStaffService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "SmsStaffController" , description = "用户模块")
@RequestMapping("/staff")
@CrossOrigin(allowCredentials = "true")
public class SmsStaffController {


    @Autowired
    private SmsStaffService smsStaffService;


    @ApiOperation("查询用户")
    @RequestMapping(value = "/selectAll",method = RequestMethod.POST)
    public CommonResult<List<SmsStaff>> listAll(){

        List<SmsStaff> list = smsStaffService.selectAll();
        return CommonResult.success(list);
    }


    @ApiOperation("新增用户")
    @RequestMapping(value = "/create",method = RequestMethod.POST)
    public CommonResult create(SmsStaff smsStaff){

     SmsStaff staff  =  smsStaffService.createUser(smsStaff);

     return CommonResult.success(staff);

    }


    @ApiOperation("更新用户信息")
    @RequestMapping(value = "/update" , method = RequestMethod.POST)
    public CommonResult update(SmsStaff smsStaff){

      SmsStaff staff  = smsStaffService.updateUser(smsStaff);

      return CommonResult.success(staff);

    }


    @ApiOperation("删除用户")
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public CommonResult delete(@RequestParam("ids") List<Long> ids){

        int count = smsStaffService.delete(ids);
        if (count>0){
            return CommonResult.success(count,"删除成功");
        }
        return CommonResult.failed("删除失败");
    }


}
